package rpg.writer.app.player;

import javax.swing.JPanel;

import rpg.client.model.Actor;
import rpg.engine.client.GameEngineFacade;
import rpg.writer.app.WriterJFrame;

public class ClientJPanel extends JPanel {
    /**
     * 
     */
    private static final long serialVersionUID = -2876981519520842851L;

    private final WriterJFrame writer;
    private final CreateCharacterJPanel newCharacterClient = new CreateCharacterJPanel(this);
    private final PlayerJPanel player = new PlayerJPanel(this);

    public ClientJPanel(WriterJFrame top) {
        super();
        writer = top;
    }

    private void moveToTop(JPanel panel) {
        removeAll();
        add(panel);
        writer.pack();
    }

    public void play(Actor pc) {
        moveToTop(player);
        player.launch(pc);
    }

    public void repack() {
        writer.pack();
        writer.repaint();
    }

    public void startGame(final GameEngineFacade facade) {
        newCharacterClient.setEngine(facade);
        player.setEngine(facade);
        moveToTop(newCharacterClient);
    }
}
